package fr.esiag.isidis.epp.Interface;

import java.io.IOException;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

import fr.esiag.isidis.epp.generatedClasses.PointConso;

public class TakeData {

	public Data takeDataFromString(String json) {
		
		ObjectMapper mapper = new ObjectMapper();
			try {
				Data data = mapper.readValue(json, Data.class);
				return data;
			} catch (JsonParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (JsonMappingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return null;
	}
	 public static void main(String[] args) {
		 String json = "{\"datedeb\":\"10/10/2012\",\"datefin\":\"10/12/2012\",\"id\":[1,2,3],\"filename\":\"test\"}";
		 TakeData t = new TakeData();
		Data d = t.takeDataFromString(json);
		System.out.println("mon Json : " + json);
		 System.out.println(d.toString());
	 }
}
